package br.com.diego.system.controller.consultapermissao;

import br.com.diego.system.controller.cadastropermissao.PermissaoVo;
import br.com.diego.system.entity.permissao.Permissao;
import br.com.diego.system.manager.permissao.PermissaoManager;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;

public class ConsultaPermissaoBuilder {

    @Autowired
    private ConsultaPermissaoFactory consultaPermissaoFactory;
    
    @Autowired
    private PermissaoManager permissaoManager;

    public PermissaoVo retornar(PermissaoVo permissaoVo) {
        Permissao permissao = new Permissao();
        permissao = permissaoManager.buscarPeloId(permissaoVo.getId());
        if (permissao != null) {
            PermissaoVo vo = new PermissaoVo(permissao);
            return vo;
        }
        return null;
    }

    public List<PermissaoVo> consultar(ConsultaPermissaoVo consultaPermissaoVo) {        
        return consultaPermissaoFactory.consultar(consultaPermissaoVo);
    }
}
